package com.sunny.blockqueue;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;

public class Test {

    private static final int LENGTH = 10;
    private static final int NUM = 5;

    public static void main(String[] args) {

        ExecutorService producerTP = Executors.newFixedThreadPool(NUM);
        ExecutorService consumerTP = Executors.newFixedThreadPool(NUM);
        LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue<>(LENGTH);

        for(int i=0;i<NUM;i++){
            producerTP.execute(new Producer("生产者"+i, queue));
        }
        for(int i=0;i<NUM;i++){
            consumerTP.execute(new Consumer("消费者"+i, queue));
        }

    }

}
